const mysql = require('mysql')
//链接数据库
const con=mysql.createConnection({
    port:'3306',
    host:'localhost',
    user:'root',
    password:'521369',
    database:'data2'
})
con.connect()
//通过sql语句请求数据库
function query(sql){
    return new Promise((resolve,reject)=>{
        con.query(sql,(err,data)=>{
            if(err){
                reject(err)
            }else{
                resolve(data)
            }
        })
    })
}
module.exports = query;

